/*
 *------------------------------------------------------------------------------
 * @File      :    tp2803_bt.c
 * @Date      :    2021-9-22
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */
#include "ei_comm_panel.h"
#include <fcntl.h>
#include "panel_usr.h"
#include "ei_math.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

#define TP2803_WIDTH	(720)
#define TP2803_HEIGHT	(576)
#define TP2803_HBP	(69)
#define TP2803_HFP	(12)
#define TP2803_HSW	(63)
#define TP2803_HACT	(TP2803_WIDTH)
#define TP2803_VBP	(19)
#define TP2803_VFP	(2)
#define TP2803_VSW	(3)
#define TP2803_VACT	(TP2803_HEIGHT)
#define TP2803_VT	(TP2803_VBP + TP2803_VFP + TP2803_VSW + TP2803_VACT)
#define TP2803_DCLK	(13500000 / 1000)
#define DCS_MDELAY_FLAG (0)

static VO_PUB_ATTR_S tp2803_config = {
    .enIntfType = VO_INTF_BT1120,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),

    .stSyncInfo.bIop = 0,
    .stSyncInfo.u16Hfb = TP2803_HFP,
    .stSyncInfo.u16Hpw = TP2803_HSW,
    .stSyncInfo.u16Hbb = TP2803_HBP,
    .stSyncInfo.u16Hact = TP2803_HACT,
    .stSyncInfo.u16Vfb = TP2803_VFP,
    .stSyncInfo.u16Vpw = TP2803_VSW,
    .stSyncInfo.u16Vbb = TP2803_VBP,
    .stSyncInfo.u16Vact = TP2803_VACT,
    .stSyncInfo.u32Pclk = TP2803_DCLK,
};

static unsigned char tp2803_init_code[] = {
    3, 0x8a, 0x02, 0x1a,
    3, 0x8a, 0x03, 0x63,
    3, 0x8a, 0x05, 0x20,
    3, 0x8a, 0x07, 0x01,
    3, 0x8a, 0x08, 0x20,
    3, 0x8a, 0x09, 0x42,
    3, 0x8a, 0x0a, 0x28,
    3, 0x8a, 0x0b, 0x05,
    3, 0x8a, 0x0c, 0x04,
    3, 0x8a, 0x0d, 0x04,
    3, 0x8a, 0x0e, 0x3c,
    3, 0x8a, 0x0f, 0x60,
    3, 0x8a, 0x10, 0x03,
    3, 0x8a, 0x11, 0x20,
    3, 0x8a, 0x12, 0x04,
    3, 0x8a, 0x13, 0x3f,
    3, 0x8a, 0x15, 0x3b,
    3, 0x8a, 0x1b, 0xa0,
    3, 0x8a, 0x1c, 0x88,
    3, 0x8a, 0x1d, 0xc1,
    3, 0x8a, 0x1e, 0x5f,
    3, 0x8a, 0x20, 0x48,
    3, 0x8a, 0x21, 0xbb,
    3, 0x8a, 0x22, 0x2e,
    3, 0x8a, 0x23, 0x8b,
    3, 0x8a, 0x29, 0x34,
    3, 0x8a, 0x2a, 0x19,
    3, 0x8a, 0x3b, 0xd0,
    3, 0x8a, 0x3c, 0x10,
    3, 0x8a, 0x3e, 0x00,
    3, 0x8a, 0x45, 0x45,
    3, 0x8a, 0xf1, 0x08,
    3, 0x8a, 0xf2, 0x0e,
    3, 0x8a, 0xf3, 0x4a,
    3, 0x8a, 0xf4, 0x61,
    3, 0x8a, 0x3a, 0x00,
    3, 0x8a, 0xff, 0xff,
};

EI_S32 panel_tp2803_get_panel_attr(PANEL_TYPE_E enPanelType, PANEL_TYPE_ATTR_S *pstPanelAttr)
{
    pstPanelAttr->stVoPubAttr = tp2803_config;

    return EI_SUCCESS;
}

EI_S32 panel_tp2803_get_panel_init_code(PANEL_TYPE_E enPanelType, PANEL_INIT_CODE_TYPE *init, EI_U32 *pLen)
{
    *init = &tp2803_init_code[0];
    *pLen = EI_ARRAY_SIZE(tp2803_init_code);
    return EI_SUCCESS;
}

PANEL_OBJ_S stPanelTp2803Obj = {
    .pfnGetPanelAttrByPanel = panel_tp2803_get_panel_attr,
    .pfnGetPanelInitCodeByPanel = panel_tp2803_get_panel_init_code,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

